package cn.lg.soar.core.handler.log;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 操作日志收集器
 * @author luguoxiang
 * @date 2022/4/26
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Lazy
@EnableScheduling // 使能定时器
@ConditionalOnMissingBean(ILogCollector.class)
public class DefaultLogCollector extends LogCollectorSupport {

    public DefaultLogCollector(IOperationLogSaveService operationLogSaveService) {
        super(operationLogSaveService);
    }

    /**
     * 定时保存日志，秒级时效性
     */
    @Scheduled(fixedDelay = 1_000)
    public void scheduled() {
        saveLog();
    }

}
